export default class MainLine<T extends Function> {
    /**在 Promise 执行过程中不接收新 Event */
    lazy = false;
    /*  内部的 Promise 队列 */
    _line = Promise.resolve();
    constructor({ lazy = false } = {}) {
        Object.assign(this, { lazy });
    }
    working = false; // 内部用于锁定状态的变量
    addEvent(func: T) {
        if (this.lazy && this.working === true) return;
        this._line = this._line
            .then(() => func())
            .finally(() => (this.working = false));
        this.working = true;
        return this._line;
    }
}
